import {
    createPermissionService,
    deletePermissionService,
    getPermissionListService,
    getPermissionDetailService,
    updatePermissionService,
    getItemsService,
    getUserPermissionListService,
} from "@/services/admin/permission";
import express from "express";

const router = express.Router();

router.get("/userPermission", (req, res) => {
    /*
		#swagger.tags = ['管理端权限']
        #swagger.path = '/admin-api/permission/userPermission'
        #swagger.description = '获取当前用户所有权限'
        #swagger.security = [{"bearerAuth": []}]
    */
    getUserPermissionListService(req, res);
});

router.get("/", (req, res) => {
    /*
		#swagger.tags = ['管理端权限']
		#swagger.path = '/admin-api/permission'
		#swagger.description = '获取权限分页数据'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.parameters['page'] = { in: 'query', description: '页号', type: 'integer' }
		#swagger.parameters['pageSize'] = { in: 'query', description: '每页个数', type: 'integer' }
		#swagger.parameters['name'] = { in: 'query', description: '权限名', type: 'string' }
		#swagger.parameters['key'] = { in: 'query', description: '权限标识', type: 'string' }
		#swagger.parameters['type'] = { in: 'query', description: '权限类型', type: 'string' }
	*/
    getPermissionListService(req, res);
});
router.get("/:_id", (req, res) => {
    /*
		#swagger.tags = ['管理端权限']
		#swagger.path = '/admin-api/permission/{_id}'
		#swagger.description = '获取指定权限'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.parameters['_id'] = { in: 'path', description: '权限ID', type: 'string', required: true }
	*/
    getPermissionDetailService(req, res);
});
router.get("/items", (req, res) => {
    /*
		#swagger.tags = ['管理端权限']
		#swagger.path = '/admin-api/permission/items'
		#swagger.description = '父查子分页'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.parameters['page'] = { in: 'query', description: '页号', type: 'integer' }
		#swagger.parameters['pageSize'] = { in: 'query', description: '每页个数', type: 'integer' }
		#swagger.parameters['name'] = { in: 'query', description: '权限名', type: 'string' }
		#swagger.parameters['key'] = { in: 'query', description: '权限标识', type: 'string' }
		#swagger.parameters['type'] = { in: 'query', description: '权限类型', type: 'string' }
	*/
    getItemsService(req, res);
});
router.post("/", (req, res) => {
    /*
		#swagger.tags = ['管理端权限']
		#swagger.path = '/admin-api/permission'
		#swagger.description = '创建权限'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.requestBody = {
			required: true,
			content: {
				"application/json": {
					schema: {
						type: "object",
						required: ['name','key','type'],
						properties: {
							name: { description: '权限名', type: 'string' },
							key: { description: '权限标识', type: 'string' },
							status: { description: '状态', type: 'boolean' },
							desc: { description: '描述', type: 'string' },
							type: { description: '权限类型', type: 'string' },
							path: { description: '页面链接', type: 'string' },
							label: { description: '页面名称', type: 'string' },
							component: { description: '组件地址', type: 'string' },
							icon: { description: '菜单图标', type: 'string' },
							children: { description: '子权限', type: 'array', items: { type: 'string' } }
						}
					}
				}
			}
		}
	*/
    createPermissionService(req, res);
});
router.put("/", (req, res) => {
    /*
		#swagger.tags = ['管理端权限']
		#swagger.path = '/admin-api/permission'
		#swagger.description = '更新权限'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.requestBody = {
			required: true,
			content: {
				"application/json": {
					schema: {
						type: "object",
						required: ['_id'],
						properties: {
							_id: { description: '权限ID', type: 'string' },
							name: { description: '权限名', type: 'string' },
							key: { description: '权限标识', type: 'string' },
							status: { description: '状态', type: 'boolean' },
							desc: { description: '描述', type: 'string' },
							type: { description: '权限类型', type: 'string' },
							path: { description: '页面链接', type: 'string' },
							label: { description: '页面名称', type: 'string' },
							component: { description: '组件地址', type: 'string' },
							icon: { description: '菜单图标', type: 'string' },
							children: { description: '子权限', type: 'array', items: { type: 'string' } }
						}
					}
				}
			}
		}
	*/
    updatePermissionService(req, res);
});
router.delete("/", (req, res) => {
    /*
		#swagger.tags = ['管理端权限']
		#swagger.path = '/admin-api/permission'
		#swagger.description = '删除权限'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.requestBody = {
			required: true,
			content: {
				"application/json": {
					schema: {
						type: "object",
						required: ['_id'],
						properties: {
							_id: { description: '权限ID', type: 'string' },
						}
					}
				}
			}
		}
	*/
    deletePermissionService(req, res);
});

export default router;
